#include<bits/stdc++.h>
using namespace std;
int g[1010][1010],d,max_d = -10 * 1010,n,m;
bool vis[1010];


void dfs(int st) { 
	for(int i = 1; i <= n; i++) {
		if(g[st][i] && !vis[i]) {
			vis[i] = 1;
			d += g[st][i];
			dfs(i);
			d -= g[st][i];
		}
	}
	max_d = max(max_d,d);
	vis[st] = 0;
	return;
}

int main() {
	cin >> n >> m;
	for(int i = 1;i <= m;i++) {
		int x,y,z;
		cin >> x>> y>> z;
		g[x][y] = z;
		g[y][x] = z;
	}
	for(int i = 1; i <= n; i++) {
		vis[i] = 1;
		dfs(i);
		memset(vis,0,sizeof(vis));
	}
	cout << max_d;
	return 0;
}

